﻿@model Webcar.Entitys.SEC_RECORD

@{ Layout = "~/Views/Shared/_leftPanelLayout.cshtml";}
@section LeftTree
{
     
    @{
        Html.RenderPartial("DeptTreePartialView", new Webcar.Models.DeptTreeMode { Action = "List", Controller = "Sec", ShowChild = false });
     }
}

    
<div style="margin:5px 5px 5px 5px">
@using (Html.BeginForm("Edit", "Sec", Html.ViewContext.RouteData.Values,FormMethod.Post))
{
    @Html.AntiForgeryToken()
    <div id="edit-car" style="width:700px">
    @Html.HiddenFor(a => a.SEC_NO)
    @Html.HiddenFor(a => a.CAR_NO)
    @Html.HiddenFor(a => a.DRIVER)
    @Html.HiddenFor(a => a.IS_END)

        <table class="edit-table">
            <tr>
                <td style="width: 80px; text-align: right;">*所属单位：</td>
                <td>@Html.DropDownListFor(a => a.SEC_DEPT, WebcarDataHelper.UserSuperDeptList, new { @style = "width: 100%;", @onchange = "changeDept();" })</td>
                <td style="width: 80px; text-align: right">*事故日期：</td>
                <td>@Html.CalendarFor(a => a.SEC_DATE)</td>
            </tr>

            <tr>
                <td style="width: 80px; text-align: right">*牌照号：</td>
                <td style="width: 200px">@Html.TextBoxFor(a => a.RECORD_NO, new { @style = "width: 100%;", @onkeyup = "this.value=this.value.toUpperCase();" })</td>
                <td style="width: 80px; text-align: right">*驾驶员：</td>
                <td style="width: 200px">@Html.TextBox("DriverName",(string)@ViewBag.DriverName)</td>
            </tr>
            
            <tr>
                <td style="width: 80px; text-align: right">*航程起至：</td>
                <td style="width: 200px">@Html.TextBoxFor(a => a.FROM_TO)</td>
                <td style="width: 80px; text-align: right">*事故地点：</td>
                <td style="width: 200px">@Html.TextBoxFor(a => a.SEC_PLACE)</td>
            </tr>

            <tr>
                <td style="width: 80px; text-align: right;">*事故类型：</td>
                <td>@Html.DropDownListFor(a => a.SEC_TYPE,new SelectList(WebcarDataHelper.SecType, "Item1", "Item2"))</td>
                <td style="width: 80px; text-align: right">*事故责任：</td>
                <td>@Html.DropDownListFor(a => a.SEC_DUTY,new SelectList(WebcarDataHelper.SecDuty, "Item1", "Item2"))</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">*事故程度：</td>
                <td>@Html.DropDownListFor(a => a.SEC_KIND,new SelectList(WebcarDataHelper.SecKind, "Item1", "Item2"))</td>
                <td style="width: 80px; text-align: right">*轻伤：</td>
                <td>@Html.TextBoxFor(a=>a.INJURY_EASY)</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">*重伤：</td>
                <td>@Html.TextBoxFor(a=>a.INJURY_HEAVY)</td>
                <td style="width: 80px; text-align: right">*死亡：</td>
                <td>@Html.TextBoxFor(a=>a.DIED)</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">损失金额：</td>
                <td>@Html.TextBoxFor(a => a.LOSS_MONEY, new {@readonly="readonly"  })</td>
                <td style="width: 80px; text-align: right">是否上报：</td>
                <td>@Html.CheckBoxFor(a=>a.ReportFlag)</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">*事故概况：</td>
                <td colspan="3">@Html.TextAreaFor(a => a.SEC_CAUSE,7,30,new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">责任认定：</td>
                <td colspan="3">@Html.TextAreaFor(a => a.REMARK,3,30,new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">达成协议：</td>
                <td colspan="3">@Html.TextAreaFor(a => a.PROTOCOL,3,30,new { @style = "width: 100%;" })</td>
            </tr>

        </table>
        <br />
        <div class="validation-errors">@ViewBag.ErrorMessage</div>
    </div>
    <table style="width:700px">
        <tr>
            <td style="width:650px"></td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.Name = "Button1";
                    settings.Text = CurrentUser.CheckPermission(PermissionManager.编辑安全事故) ? "保存" : "无权限";
                    settings.Enabled = CurrentUser.CheckPermission(PermissionManager.编辑安全事故);
                    settings.UseSubmitBehavior = true;
                    settings.Width = 70;
                    settings.ControlStyle.CssClass = "button1";
                }).GetHtml()
                

            </td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.ControlStyle.CssClass = "button2";
                    settings.Name = "Button2";
                    settings.Text = "取消";
                    settings.Width = 70;
                    settings.ClientSideEvents.Click = "function(s, e){history.back(); }";
                }).GetHtml()
            </td>
        </tr>

    </table>
}
</div>            
 

<script type="text/javascript">
    $(function () {
        changeDept();
        
        $("#RECORD_NO").change(function () {
            $("#CAR_NO").val("");
        });
        $("#DriverName").change(function () {
            $("#DRIVER").val("");
        });
        
    });
    function changeDept() {
        setCarAutoComplete("RECORD_NO", $("#SEC_DEPT").val(),
            '@Url.Action("GetAutoCompleteCar","Common")',
                function (event, ui) {
                    $("#CAR_NO").val(ui.item.key);
                }
            );
        setDriverAutoComplete("DriverName", $("#SEC_DEPT").val(), '@Url.Action("GetAutoCompleteDriver","Common")',
            function (event, ui) {
                $("#DRIVER").val(ui.item.key);
            });
        };
</script>    